package com.ecable.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Vector;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ecable.bean.ProfileTO;
import com.ecable.daoImpl.ConnectionDaoImpl;
import com.ecable.util.UtilConstants;

public class ViewOperCoustomerComplaintsAction extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;


	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doPost(request, response);
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

               
		String path="";
		String state=request.getParameter("state");
		String district=request.getParameter("district");
		String city=request.getParameter("city");
		System.out.println(state);
		System.out.println(district);
		System.out.println(city);
		Vector<ProfileTO> vpf=null;
		
		try{
			vpf=new ConnectionDaoImpl().viewOperCustomerComplaints(state,district,city);
			
			
			if(!vpf.isEmpty()){
				
				request.setAttribute("status", UtilConstants._Complaints_INFO);
	
				request.setAttribute("vpf", vpf);
				
				path=UtilConstants._VIEW_operate__Customer_Complaints;
		
			}
			else
			{
		
				request.setAttribute("status", UtilConstants._operator__Complaints);
				path=UtilConstants._VIEW_operate__Customer_Complaints;
				
			}
			
		}
		catch (Exception e) {
			
			request.setAttribute("status", UtilConstants._INVALIED_ENTRY);
			path=UtilConstants._VIEW_operate__Customer_Complaints;
			
		}
		RequestDispatcher rd=request.getRequestDispatcher(path);
		
		rd.forward(request, response);
		
   }

}
